!= (Not Exactly Matching Operator)
Syntax
Arguments
- Operand1Any Type
A value or expression of any type.
- Operand2Any Type
A value or expression of any type.
Returns
- ResultLogical
Returns .t., Operand1 and Operand2 are not equal, otherwise .f.
Description
The Not Exactly Matching operator returns .T. (TRUE) if the expressions on both sides of the operator both, Operand1 and Operand2, are of different types or have different values.
Discussion
If two character strings have different characters, different case, or a different number of trailing blanks, then Not Exactly Matching operator will return .T. (TRUE).
The opposite of "!=" is "==" ( Exactly Matching Operator ).
When comparing a character field to a string, remember that the length of the field is pre-defined. If the field is assigned fewer characters than its defined length, the remainder of the field is padded with spaces. The Not Exactly Matching operator does not automatically remove trailing blanks.
Examples:
Since the number of trailing blanks are different
? "Foley" != "Foley " = .T.
Since the case is different
? "Foley" != "foley" = .T.
Since the case of the characters does not match
? "Regan" != "regan" = .T.
Since the blanks at the end of the strings are not trimmed
? "Regan" != "Regan " = .T.
See Also